package com.jvbc.xoso.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DataBaseHelper extends SQLiteOpenHelper{
	private static final int DATABASE_VERSION = 1;
	private static final String DATABASE_NAME = "news.db";
	
	
	public static final String TABLE_DANHMUC = "danhmuc";
	public static final String KEY_ID = "_id";
	public static final String KEY_IDBAO = "BaoID";
	public static final String KEY_MUC = "Muc";
	public static final String KEY_LINK = "Link";
	
	public static final String TABLE_NEWSPAGE="newspage";
	public static final String KEY_PAGEID = "PageID";
	public static final String KEY_NAME = "Name";
	
	/*private static final String CREATE_NEWSPAGE_TABLE="create table "+TABLE_NEWSPAGE + "("
			+ KEY_IDBAO + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," + KEY_NAME + " TEXT UNIQUE)";*/
	
	private static final String CREATE_DANHMUC_TABLE = "create table " + TABLE_DANHMUC + "("
			+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " + KEY_IDBAO + " INTEGER, "
			+ KEY_MUC + " TEXT, " + KEY_LINK + " TEXT UNIQUE NOT NULL)";
	
	
	public DataBaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		//db.execSQL(CREATE_NEWSPAGE_TABLE);
		db.execSQL(CREATE_DANHMUC_TABLE);
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		//db.execSQL("DROP TABLE IF EXITS" + TABLE_NEWSPAGE);
		db.execSQL("DROP TABLE IF EXITS" + TABLE_DANHMUC);
		onCreate(db);
	}

}
